<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // call
    function getInfo(age, vip) {
      return {
        name: this.name,
        age,
        vip
      }
    }
    let obj1 = {
      name: "wsh"
    }

    let newCall = function(obj) { 
      obj = obj || window
      let arr = []
      // 第一个参数为对象,需要从第二个参数开始取
      for (let index = 1; index < arguments.length; index++) {
        arr.push(arguments[index])
      }
      // this 为调用newCall的方法本身
      obj.fn = this
      let res = obj.fn(...arr)
      delete obj.fn
      return res 
    }
    Function.prototype.newCall = newCall
    console.log(getInfo.newCall(obj1, 18, "vip"));


  </script>
</body>

</html>